#ifndef _MY_POOL_H_
#define _MY_POOL_H_

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

#define EMPTY 0

typedef struct job
{

	void *(*callback_fun)(void *argv);
	void *argv;
	struct job *next;

}TASK;

typedef struct
{

	pthread_mutex_t task_queue_acess;	
	pthread_cond_t task_queue_not_empty;
	pthread_cond_t task_queue_idle;
	pthread_t *thread_list;
	int task_queue_cur;
	int task_queue_max;	
	int thread_max_num;
	TASK *front;
	TASK *rear;

}POOL;

static void task_queue_init(POOL *pool, int task_queue_max);
extern POOL *pool_init(int thread_max_num, int task_queue_max);
static void *thread_handle(void *argv);
extern int pool_add_task(POOL *pool,void *(*function)(void *argv), void *argv);
extern void destroy_pool(POOL *pool);
#endif
